package com.zb.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zb.entity.AccounLoginInfo;
import com.zb.entity.ZjSystemLog;
import com.zb.result.PageUtil;
import com.zb.service.ZjSystemLogService;
import com.zb.system.service.ConSystemLogService;
import com.zb.vo.SystemLogListSearchVo;
import com.zb.vo.SystemLogListVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author WEN
 * @Date 2024/3/7 0007
 **/
@Service
public class ConSystemLogServiceImpl implements ConSystemLogService {
    @Resource
    private ZjSystemLogService systemLogService;

    // 获取系统操作日志列表
    @Override
    public Map<String, Object> getList(AccounLoginInfo loginInfo, SystemLogListSearchVo search) {
        List<ZjSystemLog> systemLogList = systemLogService.getList(loginInfo.getCustAccId(), search);
        return PageUtil.pageList(search.getPage(), search.getLimit(), systemLogService.getListCount(loginInfo.getCustAccId(), search), systemLogList.stream().map(log -> {
            SystemLogListVo vo = new SystemLogListVo();
            BeanUtil.copyProperties(log, vo);
            vo.setCreateTime(log.getGmtCreate());
            return vo;
        }).toList());
    }
}
